package com.sq.partner.manager.dao.impl;

/**
 * 台账信息
 * @author DingHao
 *
 */

import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Repository;
import com.sq.partner.manager.dao.IGatewayStandBookDao;
import com.sq.partner.manager.mybatis.model.GatewayStandbook;
import com.sq.partner.manager.util.LogUtil;
import com.sq.partner.manager.util.Page;
import com.sq.partner.manager.util.StrUtil;

@Repository
public class GatewayStandBookDaoImpl extends BaseDaoImpl implements IGatewayStandBookDao {
	
	private static Logger logger = LogUtil.getLog(BaseDaoImpl.class);

	@Override
	public Page queryStandBookByCriteria(Page page) throws Exception {
		
		Map<String,Object> map = (Map<String, Object>) page.getType();
		List<GatewayStandbook> countLs = queryList("queryStandBookCountByMap", map);
		long total = 0;
		for(GatewayStandbook tem: countLs){
			total+=tem.getCountTotal();
			
		}
		List<GatewayStandbook> list = queryList("queryStandBookPageOfByMap", map);
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd kk:mm:ss");
		for (GatewayStandbook tem : list) {
			GatewayStandbook standBook = tem;
			String endDate = standBook.getEndDate();
			if(StrUtil.isNotEmpty(endDate)){
				standBook.setEndDate(endDate);
			}
		}
		
		page.setTotal(total);
		page.setData(list);
		
		Map<String,Object> resultMap = new HashMap<String, Object>();
		page.setMap(resultMap);
		
		return page;
	}
	
}
	 

	 

	 

 
